package tool

import (
	"fmt"
	"time"

	common "jihe.common"
)

type verifyIdNameRes struct {
	Code string `json:"code"`
}

func VerifyIdName(idNum, name string) bool {
	res := verifyIdNameRes{}
	reqUrl := fmt.Sprintf("http://id2meta.market.alicloudapi.com/id2meta?identifyNum=%s&userName=%s", idNum, name)
	ret, _, errs := Request.Get(reqUrl).Timeout(time.Second*5).AppendHeader("Authorization", "APPCODE e83144fa046e42fbaa597b4071fad822").EndStruct(&res)
	if len(errs) != 0 {
		common.Loger.Error("verifyIdName err:%v", errs)
		return false
	}
	if ret.StatusCode != 200 {
		return false
	}
	if res.Code != "200" {
		return false
	}
	return true
}
